<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — — — </label><br/>
      <label size="large" label-width="280px">* * * 危化品泄漏扩散预警分析模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — — — </label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="300px">
      <el-form-item label="气体名称" prop="gasName">
        <el-input v-model="formData.gasName" placeholder="请输入CH4，C3H4，NH3，N2，C2H2，2OS，2H"
                  show-word-limit clearable prefix-icon='el-icon-mobile' :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="危化品类型" prop="type">
        <el-select v-model="formData.type" placeholder="请选择危化品类型" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in typeOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="容器内介质压力" prop="p">
        <el-input-number v-model="formData.p" placeholder="请输入容器内介质压力,大于101325" clearable :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="介质密度" prop="density">
        <el-input-number v-model="formData.density" placeholder="请输入介质密度" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="裂口面积" prop="a">
        <el-input-number step="0.001" v-model="formData.a" placeholder="请输入裂口面积（m^2）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="管道半径" prop="h">
        <el-input-number step="0.001" v-model="formData.h" placeholder="请输入管道半径（m）" clearable :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="气体相对分子质量" prop="m">
        <el-input-number step="0.1" v-model="formData.m" placeholder="请输入气体相对分子质量" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="气体温度" prop="t">
        <el-input-number step="0.1" v-model="formData.t" placeholder="请输入气体温度,取当前气温值，单位为K" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="泄露时间" prop="time">
        <el-input-number step="1" v-model="formData.time" placeholder="请输入泄露时间，单位：s" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>液体泄露速度（单位：kg／s）:{{Qo}};泄露半径（单位：m）:{{r}}；告警状态：{{alarm}}；液体或气体：{{type}}；扩散气体浓度分布：{{cList}}</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handlerWHP23} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {

        formData: {
          gasName: '',
          type: undefined,
          p: undefined,
          density: undefined,
          a: undefined,
          h: undefined,
          m: undefined,
          t: undefined,
          time: undefined,
        },
        rules: {
          gasName: [{
            required: true,
            message: '请输入CH4，C3H4，NH3，N2，C2H2，2OS，2H',
            trigger: 'blur'
          }],
          type: [{
            required: true,
            message: '请选择危化品类型',
            trigger: 'change'
          }],
          p: [{
            required: true,
            message: '请输入容器内介质压力',
            trigger: 'blur'
          }],
          density: [{
            required: true,
            message: '请输入介质密度',
            trigger: 'blur'
          }],
          a: [{
            required: true,
            message: '请输入裂口面积（m^2）',
            trigger: 'blur'
          }],
          h: [{
            required: true,
            message: '请输入管道半径（m）',
            trigger: 'blur'
          }],
          m: [{
            required: true,
            message: '请输入气体相对分子质量',
            trigger: 'blur'
          }],
          t: [{
            required: true,
            message: '请输入气体温度,取当前气温值，单位为K',
            trigger: 'blur'
          }],
          time: [{
            required: true,
            message: '请输入泄露时间，单位：s',
            trigger: 'blur'
          }],
        },
        typeOptions: [{
          "label": "液体",
          "value": 1
        }, {
          "label": "气体",
          "value": 2
        }],
        centerDialogVisible : false,
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handlerWHP23(this.formData).then(response => {
          console.log(response)
          this.Qo = response.Qo;
          this.r = response.r;
          if(response.r==='YES'){
            this.alarm = '告警';
          }
          else
          {
            this.alarm = '没有告警';
          }
          this.type = response.type;
          this.cList = response.cList;


          this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
